<template>
  <div class="index box">
    <div class="box-left">
      <div class="left-top">
        <div class="current-num">
          <div>人员数量统计</div>
          <p>16,825</p>
        </div>
      </div>
      <div class="left-center">
        <div class="title-box">
          <h6 id="barTitle">人员年龄分布</h6>
          <p class="unit">单位：岁</p>
        </div>
        <!-- echarts2 -->
        <div id="echarts2"></div>
      </div>
      <div class="left-bottom">
        <div class="title-box">
          <h6>人口来源分布</h6>
        </div>
        <!-- echarts3 -->
        <div id="echarts3"></div>
      </div>
    </div>

    <div class="box-center">
      <div class="center-top">
        <img src="../assets/img/jinghui.png" />
        <h1>智慧社区人口统计</h1>
      </div>
      <div class="center-center">
        <div class="data-box1 left_tb fl">
          <i class="topL"></i>
          <i class="topR"></i>
          <i class="bottomL"></i>
          <i class="bottomR"></i>
          <div class="data-title">
            <b class="data-title-left fl">[</b>
            <span>项目概览</span>
            <b class="data-title-right fr">]</b>
          </div>
          <!-- 项目概览-->
          <div class="xmglan">
            <ul class="xmgl_heard">
              <li>当前</li>
            </ul>
            <div id="xmgl_cen">
              <div class="xmgl_tb">
                <ul class="xm_cszs">
                  <li>社区面积（平米）：<span>20</span>万M</li>
                  <li>
                    <p>市政:<span>60</span><cite>%</cite></p>
                    <p>绿化:<span>80</span><cite>%</cite></p>
                  </li>
                  <li>
                    <p>房建:<span>70</span><cite>%</cite></p>
                    <p>交建:<span>80</span><cite>%</cite></p>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>

        <img src="../assets/img/line_bg.png" alt="" />
        <div class="select-box" style="height: 30px">
          <div class="select">
            <p style="color: #ffff00; font-weight: bold">NO.1山西：5500人</p>
            <p style="color: #7fff00; font-weight: bold">NO.2河南： 2990人</p>
            <p style="color: #7fffd4; font-weight: bold">NO.3河北： 2935人</p>
          </div>
        </div>
      </div>
      <div class="center-bottom">
        <h2>智慧社区绿化面积近二十年年概况</h2>
        <!-- echarts5 -->
        <div class="flasheffectoutbox">
          <div style="width: 100%; height: 500px; position: relative">
            <!-- <div class="line2 line"></div>
            <div class="line3 line"></div>
            <div class="line4 line"></div>
            <div class="line5 line"></div>
            <div class="line6 line"></div> -->
            <!--主动效-->
            <div
              class="maineffectoutbox circleeffectclass"
              style="right: 815px; bottom: 600px"
            >
              <a target="_blank">
                <img
                  class="effectposition maindataeffect"
                  src="../assets/img/maindataeffect.png"
                />
                <img
                  class="effectposition maindataspecialeffect"
                  src="../assets/img/maindataspecialeffect.png"
                />
                <img
                  class="effectposition acrossremindeffecindex"
                  src="../assets/img/maindataicon.png"
                  @click="toapp"
                />
                <span class="stagetitle" @click="toapp">智慧社区数据中心</span>
              </a>
            </div>
            <!-- 动效echarts5 -->
            <div id="echarts5"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="box-right">
      <div class="right-top">
        <div class="title-box">
          <h6>人员职业分析</h6>
        </div>
        <!-- echarts1 -->
        <div id="echarts1"></div>
      </div>
      <div class="right-bottom">
        <div class="title-box">
          <h6 id="barTitle">人口出入时间段统计</h6>
        </div>
        <!-- echarts4 -->
        <div id="echarts4"></div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  // 定义属性
  name: "Index",
  data() {
    return {};
  },
  methods: {
    echartsInit2() {
      var chartDom = document.getElementById("echarts1");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          textStyle: {
            color: "#fff",
          },
          top: "5%",
          left: "center",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 2,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "40",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 1048, name: "学生" },
              { value: 735, name: "公务员" },
              { value: 580, name: "家属" },
              { value: 484, name: "教师" },
              { value: 300, name: "医生" },
            ],
          },
        ],
      };

      option && myChart.setOption(option);
    },
    echartsInit1() {
      var chartDom = document.getElementById("echarts2");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: "Age distribution of personnel",
          subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          textStyle: {
            color: "#fff",
          },
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "31-50" },
              { value: 735, name: "16-30" },
              { value: 580, name: "51-70" },
              { value: 484, name: "0-15" },
              { value: 300, name: "71-100" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };

      option && myChart.setOption(option);
    },
    echartsInit3() {
      var chartDom = document.getElementById("echarts3");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        xAxis: {
          type: "category",
          data: ["河北", "天津", "河南", "山西", "山东", "江西", "北上广"],
        },
        legend: {
          textStyle: {
            color: "#fff",
          },
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [900, 2500, 2990, 4500, 2935, 1600, 900],
            type: "bar",
          },
        ],
      };

      option && myChart.setOption(option);
    },
    echartsInit4() {
      var chartDom = document.getElementById("echarts4");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        xAxis: {
          type: "category",
          data: ["6点-9点", "10点-12点", "13点-15点", "16点-20点", "21点-24点"],
        },
        yAxis: {
          type: "value",
        },
        legend: {
          textStyle: {
            color: "#fff",
          },
        },
        series: [
          {
            data: [800, 300, 500, 934, 1290, 800, 300],
            type: "line",
            smooth: true,
          },
        ],
      };

      option && myChart.setOption(option);
    },
    echartsInit5() {
      var chartDom = document.getElementById("echarts5");
      var myChart = echarts.init(chartDom);
      var option;

      const treeDataURI =
        "";
      const beginYear = 2010;
      const endYear = 2030;
      const lineCount = 13;
      // Basic option:
      option = {
        color: ["#e54035"],
        xAxis: {
          axisLine: { show: false },
          axisLabel: { show: false },
          axisTick: { show: false },
          splitLine: { show: false },
          name: beginYear + "",
          nameLocation: "middle",
          nameGap: 40,
          nameTextStyle: {
            color: "green",
            fontSize: 30,
            fontFamily: "Arial",
          },
          min: -2800,
          max: 2800,
        },
        yAxis: {
          data: makeCategoryData(),
          show: false,
        },
        grid: {
          top: "center",
          height: 320,
        },
        series: [
          {
            name: "all",
            type: "pictorialBar",
            symbol: "image://" + treeDataURI,
            symbolSize: [30, 55],
            symbolRepeat: true,
            data: makeSeriesData(beginYear),
            animationEasing: "elasticOut",
          },
          {
            name: "all",
            type: "pictorialBar",
            symbol: "image://" + treeDataURI,
            symbolSize: [30, 55],
            symbolRepeat: true,
            data: makeSeriesData(beginYear, true),
            animationEasing: "elasticOut",
          },
        ],
      };
      // Make fake data.
      function makeCategoryData() {
        var categoryData = [];
        for (var i = 0; i < lineCount; i++) {
          categoryData.push(i + "a");
        }
        return categoryData;
      }
      function makeSeriesData(year, negative) {
        // make a fake value just for demo.
        const r = (year - beginYear + 1) * 10;
        const seriesData = [];
        for (let i = 0; i < lineCount; i++) {
          let sign = negative
            ? -1 * (i % 3 ? 0.9 : 1)
            : 1 * ((i + 1) % 3 ? 0.9 : 1);
          seriesData.push({
            value:
              sign *
              (year <= beginYear + 1
                ? Math.abs(i - lineCount / 2 + 0.5) < lineCount / 5
                  ? 5
                  : 0
                : (lineCount - Math.abs(i - lineCount / 2 + 0.5)) * r),
            symbolOffset: i % 2 ? ["50%", 0] : undefined,
          });
        }
        return seriesData;
      }
      // Set dynamic data.
      var currentYear = beginYear;
      setInterval(function () {
        currentYear++;
        if (currentYear > endYear) {
          currentYear = beginYear;
        }
        myChart.setOption({
          xAxis: {
            name: currentYear,
          },
          series: [
            {
              data: makeSeriesData(currentYear),
            },
            {
              data: makeSeriesData(currentYear, true),
            },
          ],
        });
      }, 800);

      option && myChart.setOption(option);
    },
    toapp() {
      this.$router.push({ path: "/expressage" });
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.echartsInit1();
    this.echartsInit2();
    this.echartsInit3();
    this.echartsInit4();
    this.echartsInit5();
  },
};
</script>
<style lang='scss' scoped>
@import "../assets/css/common.css";
.box {
  width: 100%;
  height: 100%;
  background: url(../assets/img/index_bg.png) left top no-repeat;
  background-size: 100% 100%;
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  outline: none;
  .box-left {
    width: 28%;
    height: 100%;
    background: url(../assets/img/line_img.png) top right repeat-y;
    .left-top {
      width: 100%;
      height: 20.4%;
      position: relative;
      .current-num {
        width: 490px;
        height: 180px;
        position: absolute;
        margin: auto;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: url(../assets/img/border_bg01.png) top left no-repeat;
        background-size: 100% 100%;
        div {
          width: 100%;
          height: 80px;
          line-height: 80px;
          text-align: center;
          background: url(../assets/img/title_bg01.png) center center no-repeat;
          font-size: 20px;
          color: #0e94ea;
          background-size: 180px 25px;
          font-weight: 900;
        }
        p {
          font-size: 46px;
          text-align: center;
          color: white;
        }
      }
    }
    .left-center {
      width: 100%;
      height: 37%;
      position: relative;
      #echarts2 {
        width: 98%;
        height: 325px;
      }
    }
    .left-bottom {
      width: 100%;
      height: 42.6%;
      position: relative;
      #echarts3 {
        width: 98%;
        height: 325px;
      }
    }
    .title-box {
      width: 490px;
      height: 62px;
      background: url(../assets/img/box_title.png) top left no-repeat;
      background-size: 100% 100%;
      margin: auto;
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      position: relative;
      justify-content: space-between;
      h6 {
        font-size: 20px;
        color: white;
        height: 42px;
        line-height: 42px;
        margin-left: 40px;
      }
      .unit {
        font-size: 16px;
        height: 40px;
        color: #cdddf7;
        text-align: right;
        padding-right: 30px;
        line-height: 40px;
      }
    }
  }
  .box-center {
    width: 44%;
    height: 100%;
    .center-top {
      width: 100%;
      height: 8.8%;
      position: relative;
      top: 0;
      left: 0;
      background: url(../assets/img/title_border.png) bottom center no-repeat;
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 55px;
        margin-right: 15px;
      }
      h1 {
        color: #cdddf7;
        font-size: 35px;
        font-weight: 900;
        letter-spacing: 5px;
      }
    }
    .center-center {
      width: 100%;
      height: 15.3%;
      display: flex;
      flex-flow: row nowrap;
      justify-content: center;
      align-items: center;
      /*项目概览*/
      .none {
        display: none;
      }
      .xmglan {
        width: 100%;
        color: #fff;
        padding: 10px 0;
        .xmgl_heard {
          width: 100%;
          display: block;
          overflow: hidden;
          li {
            float: left;
            list-style: none;
            font-size: 16px;
            height: 24px;
            line-height: 24px;
            text-align: center;
            // background: #0068b7;
            width: 50%;
            cursor: pointer;
            border-top: 1px #032d60 solid;
            border-bottom: 1px #032d60 solid;
          }
        }
        .xm_cszs {
          margin-right: 100px;
          font-size: 16px;
          padding: 10px 10px 0 10px;
          li {
            line-height: 22px;
            overflow: hidden;
            span {
              color: #00ff00;
              padding: 0 5px 0 10px;
            }
            p {
              display: flex;
              justify-content: space-around;
              width: 60%;
              span {
                color: #00ffff;
                padding: 0;
              }
              cite {
                color: #00ffff;
              }
            }
          }
        }
      }

      .select-box {
        width: 340px;
        height: 110px;
        margin-left: 20px;
        margin-bottom: 30px;
        box-sizing: border-box;
        position: relative;
        div {
          width: 100%;
          height: 40px;
          line-height: 30px;
          position: absolute;
          bottom: 0;
          left: 0;
          font-size: 22px;
        }
      }
      img {
        width: 20px;
        height: 110px;
        margin: 0 20px;
      }
    }
    .center-bottom {
      width: 100%;
      height: 75.9%;
      position: relative;
      #echarts5 {
        width: 90%;
        height: 525px;
      }
      h2 {
        color: white;
        text-align: center;
        padding: 50px;
      }
      /*动效栏*/
      .flasheffectoutbox {
        width: 900px;
        height: 500px;
        margin: auto;
        margin-top: 10px;
        // background-image: url("../assets/img/chain_bg.png");
        background-repeat: no-repeat;
        background-position: center;
        position: relative;
      }
      .circleeffectclass {
        border-radius: 50%;
        border: rgba(0, 168, 255, 0.6) 1px solid;
        cursor: pointer;
        position: absolute;
      }
      .effectposition {
        position: absolute;
      }
      .acrossremindeffectout {
        background-color: rgba(0, 126, 255, 0.05);
        border-radius: 50%;
      }
      .acrossremindeffectoutho {
        background-color: rgba(0, 126, 255, 0.15);
      }
      .acrossremindeffectin {
        background-color: rgba(0, 126, 255, 0.3);
        border-radius: 50%;
        margin: auto;
      }
      .acrossremindeffectinho {
        background-color: rgba(0, 126, 255, 0.45);
      }
      .stagetitle {
        color: #00e4ff;
        top: 104px;
        font-size: 14px;
        font-family: "Microsoft YaHei";
        font-weight: lighter;
        display: block;
        width: 116px;
        text-align: center;
        position: absolute;
        left: -10%;
      }
      .stagearoundtitle {
        left: -25%;
        top: 85px;
      }

      // .line {
      //   position: absolute;
      //   transform-origin: left;
      //   animation-iteration-count: infinite;
      // }
      // .line2 {
      //   z-index: 1;
      //   left: 330px;
      //   top: 183px;
      //   width: 0;
      //   height: 3px;
      //   transform: rotate(21deg);
      //   animation: mm2 4s;
      //   animation-delay: 2s;
      //   animation-iteration-count: infinite;
      //   background-image: url("../assets/img/linght_ef.png");
      //   background-repeat: no-repeat;
      //   background-position: 100%;
      // }
      // .line3 {
      //   z-index: 1;
      //   left: 262px;
      //   top: 351px;
      //   width: 0;
      //   height: 3px;
      //   transform: rotate(-25deg);
      //   animation: mm 5s;
      //   animation-delay: 4s;
      //   animation-iteration-count: infinite;
      //   background-image: url("../assets/img/linght_ef.png");
      //   background-repeat: no-repeat;
      //   background-position: 100%;
      // }
      // .line4 {
      //   z-index: 1;
      //   left: 638px;
      //   top: 141px;
      //   width: 0;
      //   height: 3px;
      //   transform: rotate(-211deg);
      //   animation: mm4 3s;
      //   animation-delay: 3s;
      //   animation-iteration-count: infinite;
      //   background-image: url("../assets/img/linght_ef.png");
      //   background-repeat: no-repeat;
      //   background-position: 100%;
      // }
      // .line5 {
      //   z-index: 1;
      //   left: 679px;
      //   top: 289px;
      //   width: 0;
      //   height: 3px;
      //   transform: rotate(-172deg);
      //   animation: mm5 5s;
      //   animation-delay: 1s;
      //   animation-iteration-count: infinite;
      //   background-image: url("../assets/img/linght_ef.png");
      //   background-repeat: no-repeat;
      //   background-position: 100%;
      // }
      // .line6 {
      //   z-index: 1;
      //   left: 537px;
      //   top: 373px;
      //   width: 0;
      //   height: 3px;
      //   transform: rotate(-116deg);
      //   animation: mm6 4s;
      //   animation-delay: 0s;
      //   animation-iteration-count: infinite;
      //   background-image: url("../assets/img/linght_ef.png");
      //   background-repeat: no-repeat;
      //   background-position: 100%;
      // }
    }
  }
  .box-right {
    width: 28%;
    height: 100%;
    background: url(../assets/img/line_img.png) top left repeat-y;
    .right-top {
      width: 100%;
      height: 51%;
      box-sizing: border-box;
      padding-top: 50px;
      position: relative;
      #echarts1 {
        width: 100%;
        height: 360px;
      }
    }
    .right-bottom {
      width: 100%;
      height: 49%;
      position: relative;
      #echarts4 {
        width: 100%;
        height: 320px;
      }
    }
    .title-box {
      width: 490px;
      height: 62px;
      background: url(../assets/img/box_title.png) top left no-repeat;
      background-size: 100% 100%;
      margin: auto;
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      position: relative;
      justify-content: space-between;
      h6 {
        font-size: 20px;
        color: white;
        height: 42px;
        line-height: 42px;
        margin-left: 40px;
      }
    }
  }
}
</style>